package com.blb.mapper;

import com.blb.entity.Commodity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author txy
 * @since 2019-07-11
 */
public interface CommodityMapper extends BaseMapper<Commodity> {

    //根据商品上架时间排序，获取前七条
    @Select("SELECT * FROM t_commodity ORDER BY putaway_time DESC LIMIT 0,7")
    List<Commodity> getNewCommodity();

    //根据商品销量排序，获取前6条
    @Select("SELECT * FROM t_commodity ORDER BY sales ASC LIMIT 0,6")
    List<Commodity> getMoreCommodity();

    //根据类别id查询商品信息
    @Select("SELECT * FROM t_commodity WHERE id IN (SELECT com_id FROM t_goodstype WHERE type_id = #{typeId}) ORDER BY sales DESC")
    List<Commodity> getDetailCommodity(String typeId);
}
